#!/usr/bin/python

print str(sum(n**n for n in range(1, 1001)))[-10:]
